home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
pascal
/
tpb4_src.zip
/
MSGENTR.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1988-09-13
|
20KB
|
626 lines
{ TPBoard 4.2 Copyright (c) 1987,88 by Jon Schneider & Rick Petersen
Portions Copyright (c) 1986,87 by Steve Fox and Les Archambault
Last modified :: 7-30-88 22:00 pm
}
{$R-} {Range checking off}
{$B-} {Boolean complete evaluation off}
{$S-} {Stack checking off}
{$I+} {I/O checking on}
{$N-} {No numeric coprocessor}
Unit MsgEntr;
Interface
Uses
TPCrt, Dos, Globals, Core1, Core2,
TAccess, TPSTRING, Misc, MsgBuild;
procedure mesg_enter(to_ctrl : Char);
{==========================================================================}
Implementation
procedure mesg_enter(to_ctrl : Char);
{ Enter a new message }
type
TextPtr = ^TextRecord;
TextRecord =
record
LineNo : Integer; { Line number }
TextMsg : message; { Summary index }
next : TextPtr { Pointer to next element on list }
end;
var
stop_msg,
abort,
not_saved : Boolean;
msg_status : record_status;
ch : Char;
last_line,
to_area : Integer;
to_loc : LongInt;
TextBase,
TextLast, This : TextPtr;
ThisArea : AreaPtr;
to_fn : FirstName;
to_ln : LastName;
subj : subject;
key : StrName;
temp_user_rec : user_list;
subj_prompt : StrStd;
mname : Str13;
to_temp : Str36;
to_area_name : DosFileName;
function In_Conference : Boolean;
var
i : Integer;
This : AreaPtr;
begin
This := AreaBase;
i := 0;
while (This <> nil) and (This^.AreaName <> AreaReq) do
This := This^.next;
if This^.AreaName = AreaReq then
i := This^.AreaConf and 7;
In_Conference := test_bit(user_rec.conf_flags, i);
end;
procedure mesg_input(var last_line : Integer);
{ Input message }
var
ch : Char;
This : TextPtr;
msg : StrStd;
begin
abort := False;
WriteLn(com);
msg := ' ';
next_inpstr := '';
while (not brk) and (msg <> '') and (Online) do
begin
msg := next_inpstr;
if (last_line+1 = max_msg_lines) and (limit_lines) then
WriteLn(com, 'Two Lines Left');
if (last_line > max_msg_lines) and (limit_lines) then
msg := ''
else
begin
Write(com, last_line:2, '> ');
GetStr(msg, ch, len_msg, 'AEW');
WriteLn(com);
end;
if msg <> '' then
if MaxAvail > 400 then
begin
New(This);
if TextBase = nil then
TextBase := This
else
TextLast^.next := This;
TextLast := This;
TextLast^.LineNo := last_line;
TextLast^.TextMsg := msg;
TextLast^.next := nil;
Inc(last_line)
end
else
begin
WriteLn(com, 'Memory full.');
msg := ''
end
end
end;
procedure mesg_edit;
{ Edit selected line from message }
var
ch : Char;
i : Integer;
This, prev : TextPtr;
msg : StrStd;
begin
WriteLn(com);
Write(com, 'Edit message line...');
i := strint(prompt('Number', 2, 'E'));
This := TextBase;
prev := TextBase;
if i > 0 then
begin
while (i <> This^.LineNo) and (This <> nil) do {find line}
begin
prev := This;
This := This^.next;
end;
if This <> nil then
begin
msg := This^.TextMsg;
Write(com, i:2, '> ');
GetStr(msg, ch, len_msg, 'EL');
WriteLn(com);
if msg <> '' then
This^.TextMsg := msg;
end
else
WriteLn(com, 'Not found.')
end; {i>0}
end;
procedure mesg_delete;
{ Delete selected lines from message }
var
i, n : Integer;
This, prev : TextPtr;
begin
WriteLn(com);
i := strint(prompt('Delete line number', 2, 'E'));
n := strint(prompt(' through number', 2, 'E'))+1;
if n > last_line then
n := last_line;
n := n-i;
if (i > 0) and (n > 0) then
repeat
This := TextBase;
prev := TextBase;
while (i <> This^.LineNo) and (This <> nil) do {find line}
begin
prev := This;
This := This^.next;
end;
if This <> nil then
begin
if (prev = TextBase) and (prev = This) then
TextBase := This^.next
else
prev^.next := This^.next;
Dispose(This);
if TextLast = This then
TextLast := prev;
This := prev^.next;
while This <> nil do
begin
This^.LineNo := Pred(This^.LineNo);
TextLast := This;
This := This^.next;
end;
Dec(last_line);
Dec(n);
end
else
begin
WriteLn(com, 'Not found.');
n := 0
end;
until n = 0; {i>0}
end;
procedure mesg_insert_line;
{insert a line into text modified by ret -- 7/24/88}
var
ch : Char;
i, line_count : Integer;
This, prev, new_line : TextPtr;
msg : StrStd;
begin
WriteLn(Com);
i := strint(prompt('Insert before line...Number', 2, 'E'));
This := TextBase;
prev := TextBase;
if i > 0 then
begin
while (i <> This^.LineNo) and (This <> nil) do {find line}
begin
prev := This;
This := This^.next;
end;
if This <> nil then
begin
if (prev = TextBase) and (prev = This) then
TextBase := nil {inserting at very BEGINning}
else
TextLast := prev; {END of top part of break}
line_count := i; {save line count to current line}
mesg_input(i); {insert (input) new lines}
TextLast^.next := This; {connect tail of mesg to
the newly inserted lines}
line_count := i-line_count; {calculate # of new lines}
while This <> nil do
begin
This^.LineNo := This^.LineNo+line_count;
TextLast := This;
This := This^.next;
end;
Last_line := Last_line+line_count {update total line count}
end
else
WriteLn(Com, 'Not found.')
end; {i>0}
end;
procedure mesg_print;
{ Display message currently being edited }
var
This : TextPtr;
begin
WriteLn(com);
if user_rec.fn <> 'SYSOP' then
WriteLn(com, 'From: ', UserFullName)
else
WriteLn(com, 'From: Sysop');
if to_fn = '' then
WriteLn(com, ' To: All')
else
begin
st := to_fn+' '+to_ln;
caps_to_mixed(st);
WriteLn(com, ' To: ', st);
end;
WriteLn(com, ' Re: ', subj);
WriteLn(com);
This := TextBase;
while (not brk) and (This <> nil) do
begin
WriteLn(com, This^.LineNo:2, ': ', This^.TextMsg);
This := This^.next
end
end;
procedure mesg_save(to_loc : LongInt; subj : subject; var stop_msg : Boolean);
{ Save message to disk }
var
Start,
line_count : Integer;
This : TextPtr;
file_time : tad_array;
Str : StrTAD;
begin
WriteLn(com);
if (msg_status = private) and (test_bit(user_rec.flags, 2)) then
msg_status := restricted;
if (msg_status = private) and (user_rec.access >= val_acc) and (valid_pw) and (not test_bit
(user_rec.flags,
3)) then
if ask('Do you want this message to be public', 'N') then
begin
if restrict_public then
msg_status := restricted
else
msg_status := public;
end;
if msg_status = restricted then
WriteLn(com, 'Msg. available after Sysop Approval');
Start := FileSize(mesg_file);
Seek(mesg_file, Start);
line_count := 0;
This := TextBase;
while This <> nil do
begin
Write(mesg_file, This^.TextMsg);
Inc(line_count);
This := This^.next
end;
if line_count > 0 then
begin
GetTAD(file_time);
Str := FormTAD(file_time);
if Str = 'No Date' then
FillChar(file_time, SizeOf(file_time), 0);
Seek(summ_file, 0);
Read(summ_file, summ_rec);
with summ_rec do
begin
date := file_time;
status := msg_status;
Area := to_area;
Inc(num); { message number}
num_prev := 0; {for protecting pvt. msgs until released}
num_next := user_rec.access;
user_from := user_loc;
user_to := to_loc;
subject := subj;
st_rec := Start;
size := line_count
end;
Seek(summ_file, 0);
Write(summ_file, summ_rec);
Seek(summ_file, FileSize(summ_file));
Write(summ_file, summ_rec);
mesg_insert(2);
case msg_status of
private :
Write(com, 'Private');
public, restricted :
Write(com, 'Public')
end;
WriteLn(com, ' message ', summ_rec.num, ' filed ', Str)
end
else
WriteLn(com, 'Message not filed.');
stop_msg := True
end;
procedure mesg_quit(var stop_msg : Boolean);
{ Return to command mode }
begin
WriteLn(com);
WriteLn(com, 'Message not filed.');
stop_msg := True;
mult_cmds := False;
Cmd_Queue := '';
end;
begin {message enter}
abort := False;
to_area_name := '';
if (((diskfree(Ord(Upcase(HomDrv[1]))-64)) div 1024) > maxfree_abs) or
(not test_bit(user_rec.flags, 4)) then
begin
if (diskfree(Ord(Upcase(HomDrv[1]))-64) div 1024) <= maxfree_mslimit then
begin
limit_lines := True;
max_msg_lines := maxfree_lines; {restrict because not enough space left on disk}
end;
if (user_rec.access < val_acc) and valid_pw then
list('D');
WriteLn(com);
if user_rec.fn <> 'SYSOP' then
WriteLn(com, 'From: ', UserFullName)
else
WriteLn(com, 'From: Sysop');
OK := False;
if In_Conference then
msg_status := public
else
msg_status := private;
repeat
if (user_rec.access < val_acc) or (to_ctrl = 'S') or ((to_ctrl = 'A') and (summ_rec.
user_from = 0)) then
begin
to_fn := 'SYSOP';
WriteLn(com, ' To: ', 'Sysop');
to_area := 1; {Post area}
end
else if (to_ctrl = 'A') and (summ_rec.user_from > 0) then
begin
to_loc := summ_rec.user_from;
to_area := summ_rec.Area;
ThisArea := AreaBase;
while ThisArea^.Area <> to_area do
ThisArea := ThisArea^.next;
to_area_name := ThisArea^.AreaName;
OK := True;
GetRec(DatF, to_loc, temp_user_rec);
to_fn := temp_user_rec.fn;
to_ln := temp_user_rec.ln;
st := to_fn+' '+to_ln;
caps_to_mixed(st);
WriteLn(com, ' To: ', st)
end
else if (to_ctrl = 'M') then
begin
to_loc := nwin_rec.user;
to_area := 1;
OK := True;
GetRec(DatF, to_loc, temp_user_rec);
to_fn := temp_user_rec.fn;
to_ln := temp_user_rec.ln;
st := to_fn+' '+to_ln;
caps_to_mixed(st);
WriteLn(com, ' To: ', st)
end
else
begin
to_ln := '';
st := prompt('To FULL name [CR for ALL]', len_name, 'EL');
st := StUpcase(st);
if Pos(' ', st) <> 0 then
begin
to_ln := Copy(st, (Succ(Pos(' ', st))), len_name);
Delete(st, (Pos(' ', st)), len_name);
to_fn := st
end
else
begin
to_ln := '';
to_fn := st
end;
if to_fn = 'QUIT' then
abort := True;
if to_fn = 'ALL' then
to_fn := '';
if (user_rec.fn = 'SYSOP') and (AreaSet = 0) then
to_area := 1
else
to_area := AreaSet;
end;
if to_fn = '' then
begin
to_loc := 0;
if (restrict_public or test_bit(user_rec.flags, 3)) and (not In_Conference)
then
msg_status := restricted
else
msg_status := public;
OK := True
end
else if to_fn = 'SYSOP' then
to_ln := ''
else if (to_ctrl <> 'A') and (not abort) and (to_ln = '') then
begin
to_ln := prompt('LAST name', len_ln, 'EL');
to_ln := StUpcase(to_ln);
if to_ln = 'QUIT' then
abort := True;
end;
if (not OK) and (not abort) then
begin
if to_fn+' '+to_ln = fido_sysop then
begin
to_fn := 'SYSOP';
to_ln := ''
end;
key := pad(to_ln, len_ln)+pad(to_fn, len_fn);
FindKey(IdxF, to_loc, key);
if not OK then
begin
WriteLn(com, to_fn, ' ', to_ln, ' not known on system.');
WriteLn(com, 'type QUIT to exit .');
end;
end;
until (not Online) or OK or abort;
if abort then
OK := False;
if OK then
begin
if not valid_pw then
begin
subj := 'Password problem';
WriteLn(com, ' Re: ', subj)
end
else if user_rec.access < val_acc then
begin
subj := 'New user';
WriteLn(com, ' Re: ', subj)
end
else if to_ctrl = 'A' then
begin
subj_prompt := summ_rec.subject;
Write(com, ' Re: ');
GetStr(subj_prompt, ch, len_subj, 'EL');
subj := subj_prompt;
WriteLn(com);
end
else if to_ctrl = 'M' then
begin
subj := 'Your Upload - '+nwin_rec.name;
WriteLn(com, ' Re: ', subj);
end
else
subj := prompt('Subject', len_subj, 'EL');
if subj = '' then
subj := 'NONE';
WriteLn(com);
TextBase := nil;
last_line := 1;
if local_online and valid_pw then
begin
if to_fn = '' then
to_temp := 'ALL'
else
to_temp := to_fn+' '+to_ln;
{$V-}
caps_to_mixed(to_temp) {$V+} ;
DispName := ' To: '+to_temp;
if to_area_name <> '' then
mname := to_area_name
else if AreaReq = 'SYSTEM' then
mname := 'POST'
else
mname := AreaReq;
WriteLn(com);
mname := Copy(mname, 1, 8);
full_screen_edit(mname+'.MSG', 'W', not_saved);
make_message(mname, to_fn, to_ln, subj);
end
else
begin
if limit_lines then
begin
WriteLn(com, 'Message is limited to ', max_msg_lines, ' lines.');
WriteLn(com);
end;
WriteLn(com, 'When Message finished, enter an empty line. <CR>');
WriteLn(com, 'Ready for message...');
mesg_input(last_line);
end;
stop_msg := False;
if (TextBase <> nil) then
begin
repeat
WriteLn(com);
st := prompt('Edit command <C><D><E><I><L><S><Q><?>', 80, 'ES?');
if Length(st) = 1 then
ch := st[1]
else
st := ' ';
case ch of
'C' :
mesg_input(last_line);
'D' :
mesg_delete;
'E' :
mesg_edit;
'I' :
mesg_insert_line;
'L' :
mesg_print;
'S' :
mesg_save(to_loc, subj, stop_msg);
'Q' :
mesg_quit(stop_msg)
else
list('E');
end;
until (not Online) or (stop_msg and (ch in ['C', 'D', 'E', 'I', 'L', 'S',
'Q']));
end
else if (not local_online) then
WriteLn(com, 'Unable to continue message - aborting. ');
while TextBase <> nil do
begin
This := TextBase; { Get rid of list elements }
TextBase := TextBase^.next;
Dispose(This)
end;
end; {OK}
end {enough disk space and allowed}
else
begin
if test_bit(user_rec.flags, 4) then
WriteLn(com, 'Unable to accept messages.')
else
WriteLn(com, 'Not enough disk space for messages.');
end;
end;
end. { of MSGENTR.PAS}